<?php
/**
 * 我的课程
 *
 * @copyright  Copyright (c) 2007-2013 ShopNC Inc. (http://www.shopnc.net)
 * @license    http://www.shopnc.net
 * @link       http://www.shopnc.net
 * @since      File available since Release v1.1
 */
defined('InShopNC') or exit('Access Invalid!');

class member_lessonControl extends MobileControl {
	private $voucherstate_arr;
	
	public function __construct(){
		parent::__construct();
		$this->isLogin();
	}
	//我的课程首页展示--课程学习
	public function indexOp(){
		$member_id = $_SESSION['member_id'];
		
		
		
		
		Tpl::showPage('member_lesson_xx');
	}
	//课程收藏
	public function member_lesson_scOp(){
			$member_id = $_SESSION['member_id'];
			$sql="SELECT * FROM #__study_collection where member_id = '".$member_id."' ";
			$pagesize = 6;
			$curpage = $_GET['curpage'];
	      	$rs=db::pageQuery($sql, $curpage, $pagesize);
	        $member_lesson_sc_list = $rs->fetchAll();
	        $page = new Page();
	        $page->setEachNum($pagesize);
	        $page->setNowPage($curpage);
			$page->setTotalNum($rs->pageRows());
	        $page->setStyle('admin');
//			Tpl::output('page',$page->show());
	        Tpl::output('member_lesson_sc_list',$member_lesson_sc_list);
					$this->_assignMobileData($page);
			Tpl::showPage('member_lesson_sc');
		
	}
	
	//记录课程下载历史
	public function study_downloadOp(){
		$study_id = $_POST['study_id'];
		$member_id = $_SESSION['member_id'];
		$video = universityModel::getVideo_link($study_id);//获取视频链接
		$param ['download_time'] = time ();
		$param ['member_id'] =$member_id;
		$param ['study_id'] = $study_id;
		$rs = Db::insert ( 'study_download', $param );
		if($rs){
			$arr['success'] = 1;
			$arr['video'] = $video;
		} else{
			$arr['success'] = 0;
		}
		
		echo json_encode($arr);
		
		
	}
	//课程下载
	public function member_lesson_xzOp(){
			$member_id = $_SESSION['member_id'];
			$sql="SELECT * FROM  #__study_download  ";
			$pagesize = 8;
			$curpage = $_GET['curpage'];
	      	$rs=db::pageQuery($sql, $curpage, $pagesize);
	        $member_lesson_xz_list = $rs->fetchAll();
	        $page = new Page();
	        $page->setEachNum($pagesize);
	        $page->setNowPage($curpage);
			$page->setTotalNum($rs->pageRows());
	        $page->setStyle('admin');
	        Tpl::output('member_lesson_xz_list',$member_lesson_xz_list);
					$this->_assignMobileData($page);
		Tpl::showPage('member_lesson_xz');
	}
	//课程购买记录
	public function member_lesson_xxOp(){
			$member_id = $_SESSION['member_id'];
			$sql="SELECT * FROM  #__study_log  ";
			$pagesize = 8;
			$curpage = $_GET['curpage'];
	      	$rs=db::pageQuery($sql, $curpage, $pagesize);
	        $member_lesson_xx_list = $rs->fetchAll();
	        $page = new Page();
	        $page->setEachNum($pagesize);
	        $page->setNowPage($curpage);
			$page->setTotalNum($rs->pageRows());
	        $page->setStyle('admin');
	        Tpl::output('member_lesson_xx_list',$member_lesson_xx_list);
					$this->_assignMobileData($page);
		Tpl::showPage('member_lesson_xx');
		
		
	}
	
}
